package boogui.member;

import java.lang.reflect.Member;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import boogui.db.BooguiDAO;
import boogui.db.IBooguiDAO;

public class SDateDAO implements ISDateDAO {
	IBooguiDAO bdao = null;
	MemberSQL msql = null;
	private String selectShowingSQL = "select sdate from showing inner join movies on showing.movno = movies.movno "
			+ "inner join cinema on showing.cineno = cinema.cineno where title=? and location=? ";

	public SDateDAO() {
		bdao = new BooguiDAO();
		msql = new MemberSQL();
	}

	// sdate 조회
	@Override
	public List<ShowingVO> selectShowing(String s, String d) {

		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		List<ShowingVO> result = new ArrayList<>();

		try {
			conn = bdao.openDatabase();
			pstmt = conn.prepareStatement(selectShowingSQL);
			pstmt.setString(1, s);
			pstmt.setString(2, d);
			rs = pstmt.executeQuery();

			while (rs.next()) {
				ShowingVO m = new ShowingVO();
				m.setSdate(rs.getString("sdate"));
				result.add(m);// 반드시 써줄 것

			}
		} catch (Exception ex) {
			ex.printStackTrace();
		} finally {
			bdao.closeDatabase(conn, pstmt, rs);
		}

		return result;
	}

}
